var t = require("../../api.js"), e = getApp();

Page({
    data: {
        total_price: 0,
        price: 0,
        cash_price: 0,
        total_cash: 0,
        team_count: 0,
        order_money: 0
    },
    onLoad: function(h) {
      e.pageOnLoad(this, h);
      var user_info = wx.getStorageSync('user_info');
      if (!user_info) {
        wx.redirectTo({
          url: '/pages/login/login',
        })
        return false;
      } else if (!user_info.is_supplier) {
        wx.redirectTo({
          url: '/pages/ghs-apply/ghs-apply',
        })
        return false;
      }

        var a = this;
        wx.showLoading({
            title: "正在加载",
            mask: !0
        }), e.request({
            url: t.supplier.get_info,
            success: function(t) {
                0 == t.code && (a.setData({
                    user_info:t.data.user_info,
                    supplier:t.data.supplier,
                    price:t.data.price
                }))
            },
            complete: function() {
                wx.hideLoading();
            }
        });
    },
    onReady: function() {},
    onShow: function() {

    },
    supplierOrder:function(supplier){
        var supplier_id =supplier.currentTarget.dataset.id;

        e.request({
            url: t.supplier.supplier_order,
            data: {
                id: supplier_id
            },
            success: function(t) {
                wx.showModal({
                    title: "提示",
                    content: t.msg,
                    showCancel: !1,
                    success: function(t) {

                    }
                });
            }
        });



    },
    checkUser: function() {

    },
    loadData: function() {

    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    apply: function(a) {
        var o = wx.getStorageSync("share_setting"), i = wx.getStorageSync("user_info");
        1 == o.share_condition ? wx.navigateTo({
            url: "/pages/add-share/index"
        }) : 0 != o.share_condition && 2 != o.share_condition || (0 == i.shop_id ? wx.showModal({
            title: "申请成为团长",
            content: "是否申请？",
            success: function(n) {
                n.confirm && (wx.showLoading({
                    title: "正在加载",
                    mask: !0
                }), e.request({
                    url: t.commander.join,
                    method: "POST",
                    data: {
                        form_id: a.detail.formId
                    },
                    success: function(t) {
                        0 == t.code && (0 == o.share_condition ? (i.is_distributor = 2, wx.navigateTo({
                            url: "/pages/add-share/index"
                        })) : (i.is_distributor = 1, wx.redirectTo({
                            url: "/pages/share/index"
                        })), wx.setStorageSync("user_info", i));
                    },
                    complete: function() {
                        wx.hideLoading();
                    }
                }));
            }
        }) : wx.navigateTo({
            url: "/pages/add-share/index"
        }));
    },
    saoma: function () {
        wx.scanCode({
            success(res) {
                wx.navigateTo({
                    url: '../../' + res.path

                })
            }
        })
    }
});